package com.yanftch.stopcoding.storage

import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
import com.yanftch.stopcoding.config.DefaultConfig

@Service(Service.Level.APP)
@State(name = "StopCodingPluginState", storages = [Storage("stop_coding_settings.xml")])
class PluginState : PersistentStateComponent<PluginState> {
    var imageSrc: String = DefaultConfig.DEFAULT_IMAGE_SRC
    var textSrc: String = DefaultConfig.DEFAULT_TEXT_SRC
    var minute: Int = DefaultConfig.DEFAULT_PERIOD_MINUTES
    var switch: Boolean = true
    var dialogTitle: String = DefaultConfig.DEFAULT_DIALOG_TITLE

    override fun getState(): PluginState {
        return this
    }

    override fun loadState(pluginState: PluginState) {
        XmlSerializerUtil.copyBean(pluginState, this)
    }
}